<template>
  <div class="classes">
    <div class="header">
      <img src="./image/classLogo.png" alt="" @click="goHome">
      <button class="btn">打开</button>
    </div>
    <div class="introduce">
      <div class="bookMessage">
        <div class="bookPic">

          <img class="pic" :src="`//imagev2.xmcdn.com/${bookInfo.cover}`" alt="">
          <!-- <img class="pic" src="./image/book.png" alt=""> -->
          <img class="bacPic" src="./image/music.png" alt="">
        </div>
        <div class="name">
          <text>{{ bookInfo.title }}</text>
          <!-- <text>哈哈哈哈哈哈哈</text> -->
          <div class="author">
            <img class="authorPic" :src="`//imagev2.xmcdn.com/${bookInfo.cover}`" alt="">
            <text>丹田房评书</text>
          </div>
          <hr />
          <text>已订阅178.00万人</text>
        </div>
      </div>
      <div class="bookMessageImg">
        <img :src="`//imagev2.xmcdn.com/${bookInfo.cover}`" alt="">
      </div>
      <div class="bookContent" @click="changHeight" ref="content">
        <div class="content" ref="contentRef"></div>
        <div class="white" ref="img">
          <img class="moreContent" src="./image/箭头_页面_向下.png" alt="" @click="">
        </div>
      </div>
      <div class="moreBooks">
        <button>
          打开APP, &nbsp;&nbsp;&nbsp;完整收听
        </button>
      </div>
    </div>
    <div class="showList">
      <div class="listHeader">
        <text class="listName">节目(35)</text>
        <div class="changeList">
          <img src="./image/排序.png" alt="">
          <div>切换顺序</div>
        </div>
      </div>
      <ul class="listContent">
        <li class="content" v-for="item in VideoList" :key="item.id">
          <div class="left">
            <img src="./image/播放.png" alt="">
            <text>{{ item.trackInfo.title }}</text>
          </div>
          <img src="./image/下载.png" alt="">
        </li>
        <li class="botton">
          <text>加载更多</text>
          <img src="./image/下拉.png" alt="">
        </li>
      </ul>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
  name: 'Classea'
})
</script>
<script lang="ts" setup>
import { ref, onMounted } from 'vue';
import { getBookDetailApi, getVideoApi } from '@/api/detail'
import { useRoute, useRouter } from 'vue-router'

const content = ref()
const img = ref()
const changHeight = () => {
  content.value.style.height = 'auto'
  img.value.style.display = 'none'
}
const route = useRoute()


//获取书本详情
const bookInfo = ref<any>({})
const bookContent = ref<any>()
const contentRef = ref<any>()
const getBookDetail = async () => {
  const id = Number(route.params.id)
  // console.log(11111,id);

  const result: any = await getBookDetailApi(id)
  // console.log(result.albumDetailInfo.albumInfo.cover);
  bookInfo.value = result.albumDetailInfo.albumInfo
  bookContent.value = result.albumRichInfo

  //渲染内容
  console.log(contentRef.value);
  contentRef.value.innerHTML = bookContent.value.richIntro
}

//获取音频资料
const VideoList = ref<any>()
const getVideo = async () => {
  const id = Number(route.params.id)
  const result: any = await getVideoApi(id)
  console.log(result.trackDetailInfos);
  VideoList.value = result.trackDetailInfos
}

onMounted(() => {
  console.log(1111)
  getBookDetail()
  getVideo()
})
//回到主页
const router: any = useRouter()
const goHome = () => {
  router.push({ path: '/list' })
}
</script>

<style lang="less" scoped>
.header {
  background-color: #4c4d4f;
  display: flex;
  padding: 15px 10px;
  justify-content: space-between;
  align-items: center;

  img {
    width: 100px;
    height: 36px;
  }

  .btn {
    background-color: #f86442;
    color: #fff;
    border: none;
    border-radius: 50px;
    width: 66px;
    height: 30px;
  }
}

.introduce {

  .bookMessage {
    height: 145px;
    display: flex;
    align-items: center;
    padding: 20px;
    color: #fff;

    .bookPic {
      .pic {
        height: 95px;
        width: 95px;
      }

      .bacPic {
        height: 95px;
      }
    }

    .name {
      display: flex;
      flex-direction: column;
      flex: 1;

      .author {
        display: flex;
        align-items: center;
        border-bottom: 1px solid #fff;
        padding: 10px 0;

        .authorPic {
          width: 20px;
          height: 20px;
          border-radius: 50%;
        }
      }
    }
  }

  .bookContent {
    height: 150px;
    position: relative;
    margin-top: 10px;
    box-sizing: border-box;
    padding: 10px;
    overflow: hidden;

    .content {
      p {
        img {
          width: 100% !important;
        }
      }
    }

    .white {
      width: 100%;
      height: 150px;
      position: absolute;
      background: linear-gradient(to top, #fff 30%, transparent);
      top: 0;
      left: 0;
      text-align: center;

      img {
        position: absolute;
        bottom: 0;
        width: 20px;
      }
    }
  }

  .moreBooks {
    height: 40px;
    text-align: center;
    margin-top: 20px;

    button {
      background-color: #f96846;
      color: #fff;
      font-size: 16px;
      border: none;
      padding: 15px 60px;
      border-radius: 30px;
    }
  }
}

.showList {
  padding: 20px;

  .listHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;

    .listName {
      font-size: 18px;
      font-weight: 700;
    }

    .changeList {
      display: flex;
      width: 76px;
      height: 16px;
      align-items: center;
      justify-content: space-between;
      color: #a2a2a2;
    }
  }

  .listContent {
    .content {
      border-bottom: 1px solid #f7f8f9;
      display: flex;
      align-items: center;
      padding: 15px 0;
      color: #4d4d4d;
      font-size: 16px;

      .left {
        display: flex;
        align-items: center;
        flex: 1;

        img {
          margin-right: 10px;
        }
      }
    }

    .botton {
      text-align: center;
      line-height: 0px;
      height: 0px;
    }
  }
}

.bookMessageImg {
  position: absolute;
  width: 100%;
  height: 251px;
  top: 0;
  left: 0;
  filter: blur(7px);
  opacity: 6;
  z-index: -1;
  overflow: hidden;

  img {
    width: 200%;
    height: 200%;
  }
}
</style>